<?php echo $this->Html->script('jquery-ui-1.10.3.custom');?>
<?php echo $this->Html->script('jquery-ui-timepicker-addon.js');?>
<script type="text/javascript">
	jQuery(function($){
		//$(".datetime").mask("99/99/9999 99:99:99");
		$(".time").timepicker({
		    dateFormat: 'dd/mm/yy',
		    timeFormat: 'HH:mm',
		    timeOnlyTitle: 'Escolher Hora',
			timeText: 'Hora',
			hourText: 'Hora',
			minuteText: 'Minuto',
			currentText: 'Agora',
			closeText: 'Ok'
		});
		$(".date").datepicker({
		    dateFormat: 'dd/mm/yy',
		    timeFormat: 'HH:mm',
		    dayNames: ['Domingo','Segunda','Terça','Quarta','Quinta','Sexta','Sábado'],
		    dayNamesMin: ['D','S','T','Q','Q','S','S','D'],
		    dayNamesShort: ['Dom','Seg','Ter','Qua','Qui','Sex','Sáb','Dom'],
		    monthNames: ['Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'],
		    monthNamesShort: ['Jan','Fev','Mar','Abr','Mai','Jun','Jul','Ago','Set','Out','Nov','Dez'],
		    nextText: 'Próximo',
		    prevText: 'Anterior'
		});
	});
</script>
<?php echo $this->Form->create('DatasCurso'); ?>
	<fieldset>
		<legend><?php echo __('Adicionar Data para o Curso '.$curso['Curso']['nome']); ?></legend>
	<?php
		echo $this->Form->input('data', array('label'=>'Data', 'type'=>'text', 'readonly'=>true,  'class'=>'date'));
		echo $this->Form->input('hora_inicio', array('label'=>'Hora de Início', 'type'=>'text', 'readonly'=>true,  'class'=>'time'));
		echo $this->Form->input('hora_fim', array('label'=>'Hora de Fim', 'type'=>'text', 'readonly'=>true,  'class'=>'time'));
	?>
	</fieldset>
	<div class="submit">
		<?php echo $this->Form->submit(__('Adicionar data'), array('div'=>false, 'class'=>'btn btn-success')); ?>
		<?php echo $this->Html->link(__('Voltar'), array('controller'=>'cursos', 'action' => 'index'), array('class'=>'btn')); ?>
	</div>
	<div>
		<h4>Datas para Curso: </h4>
		<table class="table table-striped table-bordered">
			<tr>
				<th>Data</th>
				<th>Início</th>
				<th>Fim</th>
				<th></th>
			</tr>
			<?php foreach($curso['Datas'] as $data){?>
			<tr>
				<td><?php echo $this->Time->format('d/m/Y', $data['data_inicio']);?></td>
				<td><?php echo $this->Time->format('H:i', $data['data_inicio']);?></td>
				<td><?php echo $this->Time->format('H:i', $data['data_fim']);?></td>
				<td class="actions">
					<?php echo $this->Html->link('<i class=icon-edit></i>', '/datas_cursos/edit/'.$id_curso.'/'.$data['id'], array('class'=>'btn', 'escape'=>false, 'title'=>__('Editar')));?>
					<?php echo $this->Form->postLink("<i class=icon-trash></i>", array('action' => 'delete', $data['id']), array('class'=>'btn', 'escape'=>false, 'title'=>__('Apagar')), __('Deseja apagar essa data?')); ?>
				</td>
			</tr>
			<?php }?>
		</table>
	</div>